package easycloud.ecs.server.service;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import easycloud.ecs.common.domain.Provider;
import easycloud.ecs.common.domain.User;
import easycloud.ecs.common.repository.ProviderRepository;
import easycloud.ecs.common.service.ProviderService;

@Service
@Transactional(readOnly = true)
public class ProviderServiceImpl implements ProviderService {

	private static final Log logger = LogFactory
			.getLog(ProviderServiceImpl.class);

	@Inject
	private ProviderRepository providerRepository;

	public Provider getProvider(Integer providerid, User user) {
		Provider provider = providerRepository.findOne(providerid);
		if (provider != null && provider.getUser().equals(user)) {
			return provider;
		}
		return null;
	}

}
